﻿using Dapper;
using Model;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL.Common
{
    public static class DapperConfig
    {
        public static void Initialize()
        {
            RegisterTypeMaps();
        }

        private static void RegisterTypeMaps()
        {
            // 为每个实体类注册自定义映射
            SetTypeMapForEntity<Users>();
            SetTypeMapForEntity<UsersDTO>();
            SetTypeMapForEntity<UserRoleView>();
            SetTypeMapForEntity<UserRoles>(); 
            SetTypeMapForEntity<Jurisdiction>();
            SetTypeMapForEntity<OmPurchaseOrderDTO>();
            SetTypeMapForEntity<OmPurchaseOrder>();
            SetTypeMapForEntity<OmPurchaseOrderForAdd>();
            SetTypeMapForEntity<BiProduct>();
            SetTypeMapForEntity<BiProductDTO>();
            SetTypeMapForEntity<BiSupplier>();
            SetTypeMapForEntity<BiSupplierDTO>();
            SetTypeMapForEntity<OmPurchaseOrderDetail>();
            SetTypeMapForEntity<OmPurchaseOrderDetailForAdd>();
            SetTypeMapForEntity<SysOrganization>();
            SetTypeMapForEntity<SysOrganizationDTO>();
            SetTypeMapForEntity<GoodsType>();
            SetTypeMapForEntity<SysAttachmentDTO>();
            SetTypeMapForEntity<OmPurchaseOrderForUpdate>();
            SetTypeMapForEntity<WhInbound>();
            SetTypeMapForEntity<WareHouseDTO>();
            SetTypeMapForEntity<OmSalesOrder>();
            SetTypeMapForEntity<OmSalesOrderDetail>();
            SetTypeMapForEntity<OmSalesReturn>();
            SetTypeMapForEntity<OmSalesReturnDetail>();
            SetTypeMapForEntity<WhStockTake>();
            SetTypeMapForEntity<WhStockTakeDetail>();
            SetTypeMapForEntity<WhTransfer>();
            SetTypeMapForEntity<WhTransferDetail>();
            SetTypeMapForEntity<OmPurchaseOrderSourceDetail>();
            SetTypeMapForEntity<OmPurOrderGoodsDetail>();
            SetTypeMapForEntity<WhLocationSelect>();
            SetTypeMapForEntity<UserOrgInfo>();
            SetTypeMapForEntity<WhInventory>();
            SetTypeMapForEntity<WhInboundForAdd>();
            SetTypeMapForEntity<WhInboundDetailForAdd>();
            SetTypeMapForEntity<WhTransferForAddWhTDetail>();
            SetTypeMapForEntity<GetAllWhTransfer>();
            SetTypeMapForEntity<WhLocation>();
            SetTypeMapForEntity<WhOutbound>();
            SetTypeMapForEntity<WhOutboundDetail>();
        }

        private static void SetTypeMapForEntity<T>() where T : class
        {
            SqlMapper.SetTypeMap(typeof(T), new CustomNamingStrategy(typeof(T)));
        }
    }
}
